<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'self'; style-src 'self' 'unsafe-inline'; media-src *">
    <meta http-equiv="X-Content-Security-Policy" content="script-src 'self' 'unsafe-eval' 'unsafe-inline'; object-src 'self'; style-src 'self' 'unsafe-inline'; media-src *">
    <title>网页采集器-SpiderMan</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="js/vue.3.1.1.js" type="text/javascript"></script>
    <script src="js/httpVueLoader.js" type="text/javascript"></script>
    <script src="layui/layui.js"></script>
</head>

<body>
    <div class="layui-fluid" id="root">
        <index></index>
    </div>
</body>
<script>
    const { ipcRenderer, remote } = require('electron');
    const fs = require('fs');
    Date.prototype.Format = function (fmt) { //author: meizz 
        var o = {
            "M+": this.getMonth() + 1, //月份 
            "d+": this.getDate(), //日 
            "H+": this.getHours(), //小时 
            "m+": this.getMinutes(), //分 
            "s+": this.getSeconds(), //秒 
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
            "S": this.getMilliseconds() //毫秒 
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        }
        return fmt;
    }
    function loadAppComponent(vueApp) {
        var components = ipcRenderer.sendSync("loadComponents");
        if (components) {
            for(var i=0;i<components.length;i++){
                var component = components[i];
                var componentContent = eval('(' + component.content + ')');
                var styleContent = componentContent.style;
                vueApp.component(component.key, componentContent);
                // 动态添加样式
                if (styleContent) {
                    var style = document.createElement("style");
                    style.type = "text/css";
                    try {
                        style.appendChild(document.createTextNode(styleContent));
                    } catch (ex) {
                        style.styleSheet.cssText = styleContent;//针对IE
                    }
                    var head = document.getElementsByTagName("head")[0];
                    head.appendChild(style);
                }
            }
        }
    }
    function loadAppVueFileComponent(vueApp) {
        httpVueLoader('my-component.vue')
    }
</script>
<script>
    layui.use(['table', 'laypage', 'element'], function () {
        var vueApp = Vue.createApp({
        })
        loadAppComponent(vueApp);
        loadAppVueFileComponent(vueApp);
        window.vm = vueApp.mount('#root')
    });
</script>
<script>
    var maxLogLineNum = 100000;
    var countLine = 0;
    layui.use('form', function () {
        var $ = layui.$;
        var form = layui.form;
    })

</script>

</html>